package com.kobe.tokendemo.config;

import com.kobe.tokendemo.shiro.SimpleRealm;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.mgt.DefaultSessionManager;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import  org.apache.shiro.mgt.SecurityManager;

import javax.annotation.Resource;

/**
 * 创建 JYQ  on  2018/11/2,16:58
 */
@Configuration
public class ShiroConfig {
    @Resource
    private  SimpleRealm realm;
@Bean
public  SecurityManager securityManager(){
    DefaultWebSecurityManager securityManager= new DefaultWebSecurityManager();
     securityManager.setRealm(realm);
    SecurityUtils.setSecurityManager(securityManager);
    securityManager.setSessionManager(new DefaultSessionManager());
    return securityManager;
}
}
